import { _decorator, AudioSource, Component, Node,  assert} from 'cc';
const { ccclass, property } = _decorator;

@ccclass('AudioManger')
export class AudioManger extends Component {
    @property(Node)
    VoiceUnmute: Node = null;
    @property(Node)
    VoiceMute: Node = null;
    @property(AudioSource)
    public _audioSource: AudioSource = null;

    onLoad(){
        const audioSource = this.node.getComponent(AudioSource);
        this._audioSource = audioSource;
    }
    voiceMute(){
        if(this._audioSource.playing == true){
            this._audioSource.pause();
            this.VoiceMute.active = false;
            this.VoiceUnmute.active = true;            
        }
    }

    voiceUnmute(){
        if(this._audioSource.playing == false){
            this._audioSource.play();
            this.VoiceUnmute.active = false;
            this.VoiceMute.active = true;           
        }
    }

    start() {
        this.VoiceUnmute.active = false;
    }

    update(deltaTime: number) {
        
    }
}


